package Interview;

import java.util.Scanner;

/**
 * Created by loso on 2017/4/7.
 */
public class _jingdong_20170407Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            int num = Integer.parseInt(in.nextLine());
            StringBuilder s = new StringBuilder(in.nextLine());
            int countTou = 0;
            int porOfP = 0;
            for (int i = 0; i < num; i++) {
                if (s.charAt(i)>'0' && s.charAt(i)<= '9') {
                    porOfP = Math.max(porOfP-1,s.charAt(i) - '0');
                }
                else {
                    if (porOfP > 0) {
                        if (s.charAt(i) == 'X') {
                            countTou++;
                            s.setCharAt(i, '#');
                        }
                        porOfP--;
                    }
                }

            }
            porOfP = 0;
            for (int i = num-1; i >= 0; i--) {
                if (s.charAt(i)>'0' && s.charAt(i)<= '9') {
                    porOfP = Math.max(porOfP-1,s.charAt(i) - '0');
                }
                else {
                    if (porOfP > 0) {
                        if (s.charAt(i) == 'X') {
                            countTou++;
                        }
                        porOfP--;
                    }
                }
            }
            System.out.println(countTou);
            }


        }
    }
